Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
4d1c4c60
Kaydet (Commit)
4d1c4c60
authored
Nis 29, 2014
tarafından
Michael Stahl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
sw: remove SwFormTokensHelper implementation details from header
Change-Id: I9102caec1fec680e55e0ca66a0e1b02f41df5828
üst
a03c88ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
112 deletions
+102
-112
tox.hxx
sw/inc/tox.hxx
+3
-40
tox.cxx
sw/source/core/tox/tox.cxx
+99
-72
No files found.
sw/inc/tox.hxx
Dosyayı görüntüle @
4d1c4c60
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
#include <calbck.hxx>
#include <calbck.hxx>
#include <vector>
#include <vector>
#include <boost/optional.hpp>
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
text
{
class
XDocumentIndexMark
;
}
namespace
text
{
class
XDocumentIndexMark
;
}
...
@@ -265,43 +264,7 @@ typedef std::vector<SwFormToken> SwFormTokens;
...
@@ -265,43 +264,7 @@ typedef std::vector<SwFormToken> SwFormTokens;
class
SW_DLLPUBLIC
SwFormTokensHelper
class
SW_DLLPUBLIC
SwFormTokensHelper
{
{
/// the tokens
/// the tokens
SwFormTokens
aTokens
;
SwFormTokens
m_Tokens
;
/**
Builds a token from its string representation.
@sPattern the whole pattern
@nCurPatternPos starting position of the token
@return the token
*/
SAL_DLLPRIVATE
boost
::
optional
<
SwFormToken
>
BuildToken
(
const
OUString
&
sPattern
,
sal_Int32
&
nCurPatternPos
)
const
;
/**
Returns the string of a token.
@param sPattern the whole pattern
@param nStt starting position of the token
@return the string representation of the token
*/
SAL_DLLPRIVATE
OUString
SearchNextToken
(
const
OUString
&
sPattern
,
sal_Int32
nStt
)
const
;
/**
Returns the type of a token.
@param sToken the string representation of the token
@param pTokenLen return parameter the length of the head of the token
If pTokenLen is non-NULL the length of the token's head is
written to *pTokenLen
@return the type of the token
*/
SAL_DLLPRIVATE
FormTokenType
GetTokenType
(
const
OUString
&
sToken
,
sal_Int32
*
pTokenLen
)
const
;
public
:
public
:
/**
/**
...
@@ -309,7 +272,7 @@ public:
...
@@ -309,7 +272,7 @@ public:
@param rTokens vector of tokens
@param rTokens vector of tokens
*/
*/
SwFormTokensHelper
(
const
SwFormTokens
&
rTokens
)
:
a
Tokens
(
rTokens
)
{}
SwFormTokensHelper
(
const
SwFormTokens
&
rTokens
)
:
m_
Tokens
(
rTokens
)
{}
/**
/**
constructor
constructor
...
@@ -323,7 +286,7 @@ public:
...
@@ -323,7 +286,7 @@ public:
@return vector of tokens
@return vector of tokens
*/
*/
const
SwFormTokens
&
GetTokens
()
const
{
return
a
Tokens
;
}
const
SwFormTokens
&
GetTokens
()
const
{
return
m_
Tokens
;
}
};
};
class
SW_DLLPUBLIC
SwForm
class
SW_DLLPUBLIC
SwForm
...
...
sw/source/core/tox/tox.cxx
Dosyayı görüntüle @
4d1c4c60
...
@@ -695,27 +695,107 @@ OUString SwFormToken::GetString() const
...
@@ -695,27 +695,107 @@ OUString SwFormToken::GetString() const
}
}
// -> #i21237#
// -> #i21237#
SwFormTokensHelper
::
SwFormTokensHelper
(
const
OUString
&
rPattern
)
/**
Returns the type of a token.
@param sToken the string representation of the token
@param pTokenLen return parameter the length of the head of the token
If pTokenLen is non-NULL the length of the token's head is
written to *pTokenLen
@return the type of the token
*/
static
FormTokenType
lcl_GetTokenType
(
const
OUString
&
sToken
,
sal_Int32
*
const
pTokenLen
)
{
{
sal_Int32
nCurPatternPos
=
0
;
static
struct
{
OUString
sNm
;
sal_uInt16
nOffset
;
FormTokenType
eToken
;
}
const
aTokenArr
[]
=
{
{
SwForm
::
GetFormTab
(),
1
,
TOKEN_TAB_STOP
},
{
SwForm
::
GetFormPageNums
(),
1
,
TOKEN_PAGE_NUMS
},
{
SwForm
::
GetFormLinkStt
(),
1
,
TOKEN_LINK_START
},
{
SwForm
::
GetFormLinkEnd
(),
1
,
TOKEN_LINK_END
},
{
SwForm
::
GetFormEntryNum
(),
1
,
TOKEN_ENTRY_NO
},
{
SwForm
::
GetFormEntryTxt
(),
1
,
TOKEN_ENTRY_TEXT
},
{
SwForm
::
GetFormChapterMark
(),
1
,
TOKEN_CHAPTER_INFO
},
{
SwForm
::
GetFormText
(),
1
,
TOKEN_TEXT
},
{
SwForm
::
GetFormEntry
(),
1
,
TOKEN_ENTRY
},
{
SwForm
::
GetFormAuth
(),
3
,
TOKEN_AUTHORITY
}
};
while
(
nCurPatternPos
<
rPattern
.
getLength
()
)
for
(
size_t
i
=
0
;
i
<
SAL_N_ELEMENTS
(
aTokenArr
);
++
i
)
{
{
boost
::
optional
<
SwFormToken
>
const
oToken
(
const
sal_Int32
nLen
(
aTokenArr
[
i
].
sNm
.
getLength
());
BuildToken
(
rPattern
,
nCurPatternPos
));
if
(
sToken
.
startsWith
(
aTokenArr
[
i
].
sNm
.
copy
(
0
,
nLen
-
aTokenArr
[
i
].
nOffset
)
))
if
(
oToken
)
{
aTokens
.
push_back
(
oToken
.
get
());
if
(
pTokenLen
)
*
pTokenLen
=
nLen
;
return
aTokenArr
[
i
].
eToken
;
}
}
}
SAL_WARN
(
"sw.core"
,
"SwFormTokensHelper: invalid token"
);
return
TOKEN_END
;
}
}
boost
::
optional
<
SwFormToken
>
/**
SwFormTokensHelper
::
BuildToken
(
const
OUString
&
sPattern
,
Returns the string of a token.
sal_Int32
&
nCurPatternPos
)
const
@param sPattern the whole pattern
@param nStt starting position of the token
@return the string representation of the token
*/
static
OUString
lcl_SearchNextToken
(
const
OUString
&
sPattern
,
sal_Int32
const
nStt
)
{
{
OUString
sToken
(
SearchNextToken
(
sPattern
,
nCurPatternPos
)
);
sal_Int32
nEnd
=
sPattern
.
indexOf
(
'>'
,
nStt
);
if
(
nEnd
>=
0
)
{
// apparently the TOX_STYLE_DELIMITER act as a bracketing for
// TOKEN_TEXT tokens so that the user can have '>' inside the text...
const
sal_Int32
nTextSeparatorFirst
=
sPattern
.
indexOf
(
TOX_STYLE_DELIMITER
,
nStt
);
if
(
nTextSeparatorFirst
>=
0
&&
nTextSeparatorFirst
+
1
<
sPattern
.
getLength
()
&&
nTextSeparatorFirst
<
nEnd
)
{
const
sal_Int32
nTextSeparatorSecond
=
sPattern
.
indexOf
(
TOX_STYLE_DELIMITER
,
nTextSeparatorFirst
+
1
);
// Since nEnd>=0 we don't need to check if nTextSeparatorSecond<0!
if
(
nEnd
<
nTextSeparatorSecond
)
nEnd
=
sPattern
.
indexOf
(
'>'
,
nTextSeparatorSecond
);
// FIXME: No check to verify that nEnd is still >=0?
assert
(
nEnd
>=
0
);
}
++
nEnd
;
return
sPattern
.
copy
(
nStt
,
nEnd
-
nStt
);
}
return
OUString
();
}
/**
Builds a token from its string representation.
@sPattern the whole pattern
@nCurPatternPos starting position of the token
@return the token
*/
static
boost
::
optional
<
SwFormToken
>
lcl_BuildToken
(
const
OUString
&
sPattern
,
sal_Int32
&
nCurPatternPos
)
{
OUString
sToken
(
lcl_SearchNextToken
(
sPattern
,
nCurPatternPos
)
);
nCurPatternPos
+=
sToken
.
getLength
();
nCurPatternPos
+=
sToken
.
getLength
();
sal_Int32
nTokenLen
=
0
;
sal_Int32
nTokenLen
=
0
;
FormTokenType
eTokenType
=
GetTokenType
(
sToken
,
&
nTokenLen
);
FormTokenType
const
eTokenType
=
lcl_
GetTokenType
(
sToken
,
&
nTokenLen
);
if
(
TOKEN_END
==
eTokenType
)
// invalid input? skip it
if
(
TOKEN_END
==
eTokenType
)
// invalid input? skip it
{
{
nCurPatternPos
=
sPattern
.
getLength
();
nCurPatternPos
=
sPattern
.
getLength
();
...
@@ -791,70 +871,17 @@ SwFormTokensHelper::BuildToken( const OUString & sPattern,
...
@@ -791,70 +871,17 @@ SwFormTokensHelper::BuildToken( const OUString & sPattern,
return
eRet
;
return
eRet
;
}
}
OUString
SwFormTokensHelper
::
SearchNextToken
(
const
OUString
&
sPattern
,
SwFormTokensHelper
::
SwFormTokensHelper
(
const
OUString
&
rPattern
)
sal_Int32
nStt
)
const
{
sal_Int32
nEnd
=
sPattern
.
indexOf
(
'>'
,
nStt
);
if
(
nEnd
>=
0
)
{
// apparently the TOX_STYLE_DELIMITER act as a bracketing for
// TOKEN_TEXT tokens so that the user can have '>' inside the text...
const
sal_Int32
nTextSeparatorFirst
=
sPattern
.
indexOf
(
TOX_STYLE_DELIMITER
,
nStt
);
if
(
nTextSeparatorFirst
>=
0
&&
nTextSeparatorFirst
+
1
<
sPattern
.
getLength
()
&&
nTextSeparatorFirst
<
nEnd
)
{
const
sal_Int32
nTextSeparatorSecond
=
sPattern
.
indexOf
(
TOX_STYLE_DELIMITER
,
nTextSeparatorFirst
+
1
);
// Since nEnd>=0 we don't need to check if nTextSeparatorSecond<0!
if
(
nEnd
<
nTextSeparatorSecond
)
nEnd
=
sPattern
.
indexOf
(
'>'
,
nTextSeparatorSecond
);
// FIXME: No check to verify that nEnd is still >=0?
assert
(
nEnd
>=
0
);
}
++
nEnd
;
return
sPattern
.
copy
(
nStt
,
nEnd
-
nStt
);
}
return
OUString
();
}
FormTokenType
SwFormTokensHelper
::
GetTokenType
(
const
OUString
&
sToken
,
sal_Int32
*
pTokenLen
)
const
{
{
static
struct
sal_Int32
nCurPatternPos
=
0
;
{
OUString
sNm
;
sal_uInt16
nOffset
;
FormTokenType
eToken
;
}
const
aTokenArr
[]
=
{
{
SwForm
::
GetFormTab
(),
1
,
TOKEN_TAB_STOP
},
{
SwForm
::
GetFormPageNums
(),
1
,
TOKEN_PAGE_NUMS
},
{
SwForm
::
GetFormLinkStt
(),
1
,
TOKEN_LINK_START
},
{
SwForm
::
GetFormLinkEnd
(),
1
,
TOKEN_LINK_END
},
{
SwForm
::
GetFormEntryNum
(),
1
,
TOKEN_ENTRY_NO
},
{
SwForm
::
GetFormEntryTxt
(),
1
,
TOKEN_ENTRY_TEXT
},
{
SwForm
::
GetFormChapterMark
(),
1
,
TOKEN_CHAPTER_INFO
},
{
SwForm
::
GetFormText
(),
1
,
TOKEN_TEXT
},
{
SwForm
::
GetFormEntry
(),
1
,
TOKEN_ENTRY
},
{
SwForm
::
GetFormAuth
(),
3
,
TOKEN_AUTHORITY
}
};
for
(
size_t
i
=
0
;
i
<
SAL_N_ELEMENTS
(
aTokenArr
);
++
i
)
while
(
nCurPatternPos
<
rPattern
.
getLength
()
)
{
{
const
sal_Int32
nLen
(
aTokenArr
[
i
].
sNm
.
getLength
());
boost
::
optional
<
SwFormToken
>
const
oToken
(
if
(
sToken
.
startsWith
(
aTokenArr
[
i
].
sNm
.
copy
(
0
,
nLen
-
aTokenArr
[
i
].
nOffset
)
))
lcl_BuildToken
(
rPattern
,
nCurPatternPos
));
{
if
(
oToken
)
if
(
pTokenLen
)
m_Tokens
.
push_back
(
oToken
.
get
());
*
pTokenLen
=
nLen
;
return
aTokenArr
[
i
].
eToken
;
}
}
}
SAL_WARN
(
"sw.core"
,
"SwFormTokensHelper: invalid token"
);
return
TOKEN_END
;
}
}
// <- #i21237#
// <- #i21237#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment