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
24b402d6
Kaydet (Commit)
24b402d6
authored
Mar 02, 2012
tarafından
Noel Power
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
weed out unmatched Sub/End Sub statements when importing VBA fdo#46889
üst
101fd173
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
vbamodule.cxx
oox/source/ole/vbamodule.cxx
+48
-0
No files found.
oox/source/ole/vbamodule.cxx
Dosyayı görüntüle @
24b402d6
...
...
@@ -221,6 +221,7 @@ void VbaModule::createEmptyModule( const Reference< XNameContainer >& rxBasicLib
OUString
VbaModule
::
readSourceCode
(
StorageBase
&
rVbaStrg
,
const
Reference
<
XNameContainer
>&
rxOleNameOverrides
)
const
{
OUStringBuffer
aSourceCode
;
const
static
rtl
::
OUString
sUnmatchedRemovedTag
(
RTL_CONSTASCII_USTRINGPARAM
(
"Rem removed unmatched Sub/End: "
)
);
if
(
!
maStreamName
.
isEmpty
()
&&
(
mnOffset
!=
SAL_MAX_UINT32
)
)
{
BinaryXInputStream
aInStrm
(
rVbaStrg
.
openInputStream
(
maStreamName
),
true
);
...
...
@@ -234,6 +235,14 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg, const Reference< XNam
VbaInputStream
aVbaStrm
(
aInStrm
);
// load the source code line-by-line, with some more processing
TextInputStream
aVbaTextStrm
(
mxContext
,
aVbaStrm
,
meTextEnc
);
struct
ProcedurePair
{
bool
bInProcedure
;
sal_uInt32
nPos
;
ProcedurePair
()
:
bInProcedure
(
false
),
nPos
(
0
)
{};
}
procInfo
;
while
(
!
aVbaTextStrm
.
isEof
()
)
{
OUString
aCodeLine
=
aVbaTextStrm
.
readLine
();
...
...
@@ -244,6 +253,45 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg, const Reference< XNam
}
else
{
// Hack here to weed out any unmatched End Sub / Sub Foo statements.
// The behaviour of the vba ide practically guarantees the case and
// spacing of Sub statement(s). However, indentation can be arbitrary hence
// the trim.
rtl
::
OUString
trimLine
(
aCodeLine
.
trim
()
);
if
(
mbExecutable
&&
(
trimLine
.
matchAsciiL
(
RTL_CONSTASCII_STRINGPARAM
(
"Sub "
)
)
||
trimLine
.
matchAsciiL
(
RTL_CONSTASCII_STRINGPARAM
(
"Public Sub "
)
)
||
trimLine
.
matchAsciiL
(
RTL_CONSTASCII_STRINGPARAM
(
"Private Sub "
)
)
||
trimLine
.
matchAsciiL
(
RTL_CONSTASCII_STRINGPARAM
(
"Static Sub "
)
)
)
)
{
// this should never happen, basic doesn't support nested procedures
// first Sub Foo must be bogus
if
(
procInfo
.
bInProcedure
)
{
// comment out the line
aSourceCode
.
insert
(
procInfo
.
nPos
,
sUnmatchedRemovedTag
);
// mark location of this Sub
procInfo
.
nPos
=
aSourceCode
.
getLength
();
}
else
{
procInfo
.
bInProcedure
=
true
;
procInfo
.
nPos
=
aSourceCode
.
getLength
();
}
}
else
if
(
mbExecutable
&&
aCodeLine
.
trim
().
equalsAsciiL
(
RTL_CONSTASCII_STRINGPARAM
(
"End Sub"
))
)
{
// un-matched End Sub
if
(
!
procInfo
.
bInProcedure
)
{
aSourceCode
.
append
(
sUnmatchedRemovedTag
);
}
else
{
procInfo
.
bInProcedure
=
false
;
procInfo
.
nPos
=
0
;
}
}
// normal source code line
if
(
!
mbExecutable
)
aSourceCode
.
appendAscii
(
RTL_CONSTASCII_STRINGPARAM
(
"Rem "
)
);
...
...
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