1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include "vbacolumn.hxx"
21 #include <vbahelper/vbahelper.hxx>
22 #include <com/sun/star/frame/XModel.hpp>
23 #include <com/sun/star/table/XCellRange.hpp>
24 #include <com/sun/star/view/XSelectionSupplier.hpp>
25 #include "vbatablehelper.hxx"
26 #include "wordvbahelper.hxx"
27 #include <unotxdoc.hxx>
29 using namespace ::ooo::vba
;
30 using namespace ::ooo::vba::word
;
31 using namespace ::com::sun::star
;
33 SwVbaColumn::SwVbaColumn( const uno::Reference
< ooo::vba::XHelperInterface
>& rParent
, const uno::Reference
< uno::XComponentContext
>& rContext
, uno::Reference
< text::XTextTable
> xTextTable
, sal_Int32 nIndex
) :
34 SwVbaColumn_BASE( rParent
, rContext
), mxTextTable(std::move( xTextTable
)), mnIndex( nIndex
)
38 SwVbaColumn::~SwVbaColumn()
43 SwVbaColumn::getWidth( )
45 SwVbaTableHelper
aTableHelper( mxTextTable
);
46 return aTableHelper
.GetColWidth( mnIndex
);
50 SwVbaColumn::setWidth( sal_Int32 _width
)
53 SwVbaTableHelper
aTableHelper( mxTextTable
);
54 aTableHelper
.SetColWidth( _width
, mnIndex
);
58 SwVbaColumn::Select( )
60 SelectColumn( getCurrentWordDoc(mxContext
), mxTextTable
, mnIndex
, mnIndex
);
63 void SwVbaColumn::SelectColumn( const rtl::Reference
< SwXTextDocument
>& xModel
, const uno::Reference
< text::XTextTable
>& xTextTable
, sal_Int32 nStartColumn
, sal_Int32 nEndColumn
)
65 OUString sStartCol
= SwVbaTableHelper::getColumnStr( nStartColumn
);
66 OUString aRangeName
= sStartCol
+ OUString::number( 1 );
67 OUString sEndCol
= SwVbaTableHelper::getColumnStr( nEndColumn
);
68 sal_Int32 nRowCount
= xTextTable
->getRows()->getCount();
69 aRangeName
+= ":" + sEndCol
+ OUString::number(nRowCount
);
71 uno::Reference
< table::XCellRange
> xCellRange( xTextTable
, uno::UNO_QUERY_THROW
);
72 uno::Reference
< table::XCellRange
> xSelRange
= xCellRange
->getCellRangeByName( aRangeName
);
74 uno::Reference
< view::XSelectionSupplier
> xSelection( xModel
->getCurrentController(), uno::UNO_QUERY_THROW
);
75 xSelection
->select( uno::Any( xSelRange
) );
79 SwVbaColumn::getServiceImplName()
81 return u
"SwVbaColumn"_ustr
;
84 uno::Sequence
< OUString
>
85 SwVbaColumn::getServiceNames()
87 static uno::Sequence
< OUString
> const aServiceNames
89 u
"ooo.vba.word.Column"_ustr
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */